package org.dromara.oce.constant;

import org.dromara.common.core.constant.GlobalConstants;

/**
 * 管理用于缓存的RedisKey
 */
public class RedisKeyUtils {

    // 获取clientToken的缓存key前缀
    private static final String CLIENT_TOKEN_KEY = GlobalConstants.GLOBAL_REDIS_KEY + "clientToken";

    // 获取小程序clientToken的缓存key前缀
    private static final String APP_CLIENT_TOKEN_KEY = GlobalConstants.GLOBAL_REDIS_KEY + "appClientToken";

    /**
     * 获取小程序配置缓存key
     * @param appCode
     * @return
     */
    public static String getAppSocialKey(String appCode) {
        String key = "app_social:" + "info:" + appCode;
        return key;
    }

    /**
     * 获取access_token的key
     * @param platformType
     * @param appId
     * @return
     */
    public static String getAccessTokenKey(String platformType, String appId) {
        String key = GlobalConstants.GLOBAL_REDIS_KEY + "app_social:" + platformType + ":accessToken:" + appId;
        return key;
    }
    /**
     * 获取refresh_token的key
     * @param platformType
     * @param appId
     * @return
     */
    public static String getRefreshTokenKey(String platformType, String appId) {
        String key = GlobalConstants.GLOBAL_REDIS_KEY + "app_social:" + platformType + ":refreshToken:" + appId;
        return key;
    }


    /**
     * 获取管理账号的access_token的KEY
     * @param platformType
     * @param account   授权账户
     * @return
     */
    public static String getAccountAccessTokenKey(String platformType, String account) {
        String key = GlobalConstants.GLOBAL_REDIS_KEY + "account:" + platformType + ":accessToken:" + account;
        return key;
    }
    /**
     * 获取管理账号的refresh_token的key
     * @param platformType
     * @param appId
     * @return
     */
    public static String getAccountRefreshTokenKey(String platformType, String account) {
        String key = GlobalConstants.GLOBAL_REDIS_KEY + "account:" + platformType + ":refreshToken:" + account;
        return key;
    }


    /**
     * 获取client_token的KEY
     *
     * @param platformType 平台类型  {@link PlatformJuLangConstants}
     * @param appId        小程序appId
     * @return
     */
    public static String getClientTokenKey(String platformType, String appId) {
        String key = "app_social:" + platformType + ":clientToken:" + appId;
        return key;
    }

    /**
     * 获取client_token的KEY
     *
     * @param platformType 平台类型  {@link PlatformJuLangConstants}
     * @return
     */
    public static String getClientTokenNewKey(String platformType,String appCode) {
        return CLIENT_TOKEN_KEY+":" + platformType + ":" + appCode;
    }

    /**
     * 获取小程序client_token的KEY
     *
     * @param appCode appCode
     * @return
     */
    public static String getAppClientTokenKey(String appCode) {
        return APP_CLIENT_TOKEN_KEY+":" + appCode;
    }

    /**
     * 根据链接id，获取回传模板的KEY
     *
     * @param iaaBackTemplateId
     * @return
     */
    public String getIaaTemplateKey(Long iaaBackTemplateId) {
        String key = "app:iaaBackTemplate:" + iaaBackTemplateId;
        return key;
    }

    /**
     * 获取默认模板的KEY
     *
     * @param productType
     * @return
     */
    public String getDefaultTemplateKey(Integer productType) {
        String key = "app:templateProduct:" + productType + ":" + CommonConstantsJuLang.IS_DEFAULT_YES;
        return key;
    }


}
